home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2002 #12
/
Amiga Plus CD - 2002 - No. 12.iso
/
Tools
/
Development
/
source-highlight-1.6.1
/
tests
/
test.py
< prev
next >
Wrap
Text File
|
2002-11-17
|
675b
|
29 lines
#! /usr/bin/python
import posix
from string import splitfields
def userinfo(filename):
"""
This function returns the list of users
and a table containing users and their passwords
"""
users, table = [], {}
file = open(filename, 'r')
for line in file.readlines():
[name, password] = splitfields(line, ':')[:2]
users.append(name)
table[name] = password
return users, table
def main():
for filename in ('/etc/passwd', 'etc/passwd.bak'):
try:
users, table = userinfo(filename)
print table.keys()[3:7], table['postgres']
posix.system('ls -al ' + filename)
except:
print 'File "' + filename + '" not found!'
main()